package com.twu.biblioteca;

import java.io.IOException;

/**
 * Created by kashyapk on 05/03/14.
 */
public class MovieMenu extends Menu {
    private final Library library;
    private final Customer customer;

    public MovieMenu(Library library, Customer customer) {
        super(library,customer);
        this.library = library;
        this.customer = customer;
    }

    @Override
    public void ShowMenu() {
        String menu = "1.List Movie  2.Checkout Movie  3.Return Movie  4.Back \nEnter you choice: ";
        System.out.print(menu);
    }

    @Override
    public int MenuAction(int choice) {
        switch(choice) {
            case 1:
                for(Movie movie : library.ListMovies())
                    System.out.println(movie.getName());
                break;
            case 2:
                try {
                    System.out.print("Which movie? ");
                    String movieTitle = br.readLine();
                    System.out.println(library.CheckoutMovie(movieTitle, customer));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                break;
            case 3:
                try {
                    System.out.print("Which movie? ");
                    String movieTitle = br.readLine();
                    System.out.println(library.ReturnMovie(movieTitle, customer));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                break;
            default:
                System.out.println("Select a valid option!");
        }
        return choice;
    }
}
